﻿using System;
using System.Collections.Generic;
using System.Text;
using Model;
using System.Data;
using AppToolKit.Core.Context.Spring;

namespace BLL.Business
{
    [AutoWiring]
    public class EntityBusiness
    {
        [AutoWiring]
        public ConvertService ConvertServiceHolder { get; set; }
        [AutoWiring]
        public EntityBusinessDao Dao { get; set; }

      
        public object Load(object key,string table)
        {

            DataTrans data = Create(table);
            data.SetPrimaryKey(key);
           DataRow dr=Dao.Load(data.GetPrimaryKey() as EntityKey, data.Entity.TalbeName);

           ConvertServiceHolder.DataRowToVO(dr, data);

           return data;
        }
        public void Delete(object key,string table)
        {
            Dao.Delete(key as EntityKey, table);
        }
        public void Save(DataTrans data)
        {
            Dao.Save(data);
        }
        public void Update(DataTrans data)
        {
            Dao.Update(data);
        }
      
        public DataTrans Create(string table  )
        {
            return Dao.Create(table) as DataTrans;
        }
    }
}
